package com.ruiysoft.controller.sys;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruiysoft.controller.sys.api.SysRegionApi;
import com.ruiysoft.entity.sys.SysRegion;
import com.ruiysoft.service.sys.ISysRegionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/sysregion")
public class SysRegionApiController implements SysRegionApi {

    private static final Logger log = LoggerFactory.getLogger(SysRegionApiController.class);

    @Autowired
    private ISysRegionService sysRegionService;

    @Override
    public List<SysRegion> getByPid(Long pid) {
        Wrapper<SysRegion> wrapper = new QueryWrapper<SysRegion>().lambda().eq(SysRegion::getPid,pid);
        List<SysRegion> list = sysRegionService.list(wrapper);
        if(list.get(0).getType() > 2)
            return new ArrayList<SysRegion>();

        return list;
    }
}
